﻿using GameEntitySystem;
using TemplatesDatabase;

namespace Game
{
    public class ComponententityDodo : Component
    {
        private EntityReference lordEntityRef;

        public ComponentBody componentBody;

        public ComponentBody lordBody => componentBody;

        public Entity LordEntity => componentBody.Entity;

        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            base.Load(valuesDictionary, idToEntityMap);
            Entity entity = base.Entity;
            componentBody = entity.FindComponent<ComponentBody>();
        }

        public override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap)
        {
            base.Save(valuesDictionary, entityToIdMap);
            Entity entity = componentBody.Entity;
            lordEntityRef = EntityReference.FromId(entity, entityToIdMap);
            valuesDictionary.SetValue("LordEntity", lordEntityRef);
        }
    }
}